package com.wondertek.poms.init.service.impl;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wondertek.poms.common.constant.Constants;
import com.wondertek.poms.common.service.impl.ServiceImpl;
import com.wondertek.poms.common.utils.CopyUtils;
import com.wondertek.poms.init.po.InitTime;
import com.wondertek.poms.init.service.IInitTimeService;

/**
 * <p><b>InitTimeServiceImpl Description:</b> 初始化时间表service层实现 </p>
 * @author 窦再兴
 * <p><b>DATE</b> 2020-03-30 18:57:15</p>
 */
@Service
@Scope("prototype")
@Transactional(readOnly = false)
public class InitTimeServiceImpl extends ServiceImpl<InitTime, Long> implements IInitTimeService {
	@Override
	public InitTime deleteLogic(Long id) {
		InitTime cp = jpaRepository.getOne(id);
		InitTime.putTimeAndUser(cp);
		cp.setDel(Constants.DELETE_1);
		jpaRepository.save(cp);
		return cp;
	}

	@Override
	public InitTime merge(InitTime model) {
		InitTime.putTimeAndUser(model);
		InitTime dbo = jpaRepository.getOne(model.getId());
		CopyUtils.copyProperties(model, dbo);
		return jpaRepository.save(dbo);
	}
}